<template>
  <div class="dialogComponents">
    <el-dialog
      class="dialog-class"
      :appendToBody="props.appendToBody"
      v-model="dialogVisible"
      :width="props.width"
      :fullscreen="fullscreen"
    >
      <div class="header" v-if="props.headerStatus">
        <div class="header-left">
          <div class="headerName">{{ props.title }}</div>
          <div class="headerContent" v-if="title == '账号配置'">
            机构名称：{{ props.content }}
          </div>
        </div>
        <el-icon size="24" @click="closeChange" style="cursor: pointer">
          <Close />
        </el-icon>
      </div>
      <el-divider v-if="headerStatus" />
      <slot v-if="dialogVisible"></slot>
    </el-dialog>
  </div>
</template>
<script setup>
import { ref } from 'vue';
import bus from '@/utils/bus.js';

const dialogVisible = ref(false);
const props = defineProps({
  title: {
    type: String, // 接收的参数类型
    default: '默认文字', //默认值
  },
  content: {
    type: String,
    default: '',
  },
  width: {
    type: String,
    default: '1200',
  },
  headerStatus: {
    type: Boolean,
    default: true,
  },
  fullscreen: {
    type: Boolean,
    default: false,
  },
  isSendBus: {
    type: Boolean,
    default: false,
  },
  appendToBody: {
    type: Boolean,
    default: false,
  },
});

function openChange() {
  dialogVisible.value = true;
}

function closeChange() {
  dialogVisible.value = false;
  if (props.isSendBus) {
    bus.emit('refreshList');
  }
}
defineExpose({
  openChange,
  closeChange,
});
</script>
<style lang="scss">
.dialog-class {
  border-radius: 6px;

  .el-dialog__header {
    display: none;
  }
}
</style>
<style lang="scss" scoped>
.header {
  display: flex;
  justify-content: space-between;
  .header-left {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
  }
  .headerContent {
    margin: 8px 0 0 20px;
  }
  .headerName {
    font-size: 18px;
    font-family:
      PingFang SC-Medium,
      PingFang SC;
    font-weight: 600;
    color: #1d2129;
    line-height: 27px;
  }
}
</style>
